#include <stdio.h>

typedef unsigned float_bits;
#define TMin 0x80000000

int float_f2i(float_bits f)
{
    unsigned sign, exp, frac, last_bit;
    int i;

    sign = f >> 31;  //最高位32位
    exp = (f >> 23) & 0xff;//阶码位
    frac = f & 0x7fffff;//小数位

    if (exp == 158 && frac == 0 && sign == 1)  //处理f = TMin的情况
        i = TMin;
    else if (exp > 157 || exp == 0xff)  //处理f上溢出或f是NaN的情况
        i = TMin;
    else if (exp < 126)  //处理f下溢出
        i = 0;
    else
    {
        exp -= 127;
        frac |= 0x800000;
        if (exp > 23)
        {
            exp -= 23;
            frac <<= exp;
        }
        else if (exp < 23)
        {
            exp = 23 - exp;
            frac >>= exp;
        }
        if (sign == 1)
            i = (~frac) + 1;
        else
            i = frac;
    }
    return i;
}
int main(void)
{
    int j, k;
    float f;
  	scanf("%f",&f);    
        j = (int)f;
        k = float_f2i(i);
	 printf("原值%f : 机器 %d  函数 %d\n", f, j, k);

    return 0;
}
